package com.qianfeng.controller;

import com.qianfeng.Service.ConsumeService;
import com.qianfeng.model.Consume;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/consume_list")
public class ConsumeController extends HttpServlet {
    private ConsumeService consumeService =new ConsumeService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        response.setContentType("text/html;charset=UTF-8");
        try {
            List<Consume> list=consumeService.selectAll();
            request.setAttribute("list",list);
            request.getRequestDispatcher("consume_list.jsp").forward(request,response);

        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
